package com.j1903.contorller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.j1903.annotation.PassJwt;
import com.j1903.bean.Goods;
import com.j1903.bean.Users;
import com.j1903.service.GoodsService;
import com.j1903.service.IUsersService;
import com.j1903.util.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/goods1")
@Slf4j
@CrossOrigin
public class indesConlper {
    @Resource
    private GoodsService goodsService;
    @RequestMapping("/list")
    @PassJwt
    public JsonResult list(@RequestBody Goods goods)
    {
        try {
            QueryWrapper<Goods> qwUser=new QueryWrapper<>();
            qwUser.eq("cateId", goods.getCateId());
            List<Goods> list2=goodsService.list(qwUser);
            System.out.println(list2);
            return new JsonResult(200,"查询成功",list2);

        }catch (Exception e){
            log.error(ExceptionUtils.getStackTrace(e));
            return new JsonResult(500,"查询失败",e.getMessage());
        }
    }
}
